namespace SimpleWebServices.Security.Cryptography
{
    using System;
    using SimpleWebServices;
    using Xunit;

    public sealed class SaltFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<Salt>()
                .DerivesFrom<object>()
                .IsConcreteClass()
                .IsSealed()
                .HasDefaultConstructor()
                .Result);
        }

        [Fact]
        public void ctor()
        {
            Assert.NotNull(new Salt());
        }

        [Fact]
        public void ctor_int()
        {
            Assert.NotNull(new Salt(10));
        }

        [Fact]
        public void ctor_intZero()
        {
            Assert.Throws<ArgumentOutOfRangeException>(() => new Salt(0));
        }

        [Fact]
        public void ctor_stringNull()
        {
            Assert.Throws<ArgumentNullException>(() => new Salt(null));
        }

        [Fact]
        public void ctor_stringEmpty()
        {
            Assert.Throws<ArgumentOutOfRangeException>(() => new Salt(string.Empty));
        }

        [Fact]
        public void ctor_string()
        {
            Assert.NotNull(new Salt("XbAH5ybjSkZt+Q=="));
        }

        [Fact]
        public void opEquality_Salt_SaltTrue()
        {
            string value = "XbAH5ybjSkZt+Q==";

            Salt obj = new Salt(value);
            Salt comparand = new Salt(value);

            Assert.True(obj == comparand);
        }

        [Fact]
        public void opEquality_Salt_SaltFalse()
        {
            Salt obj = new Salt("XbAH5ybjSkZt+Q==");
            Salt comparand = new Salt();

            Assert.False(obj == comparand);
        }

        [Fact]
        public void opEquality_Salt_SaltNull()
        {
            Assert.False(new Salt() == null);
        }

        [Fact]
        public void opEquality_SaltNull_Salt()
        {
            Assert.False(null == new Salt());
        }

        [Fact]
        public void opEquality_Salt_SaltSame()
        {
            Salt obj = new Salt("XbAH5ybjSkZt+Q==");
            Salt comparand = obj;

            Assert.True(obj == comparand);
        }

        [Fact]
        public void opImplicit_string_SaltNull()
        {
            string expected = null;
            string actual = null as Salt;

            Assert.Equal<string>(expected, actual);
        }

        [Fact]
        public void opImplicit_string_Salt()
        {
            string expected = "XbAH5ybjSkZt+Q==";
            string actual = new Salt(expected);

            Assert.Equal<string>(expected, actual);
        }

        [Fact]
        public void opImplicit_Salt_stringNull()
        {
            Salt expected = null;
            Salt actual = null as string;

            Assert.Equal<Salt>(expected, actual);
        }

        [Fact]
        public void opImplicit_Salt_stringEmpty()
        {
            try
            {
                Salt obj = string.Empty;
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }

        [Fact]
        public void opImplicit_Salt_string()
        {
            string value = "XbAH5ybjSkZt+Q==";

            Salt expected = new Salt(value);
            Salt actual = value;

            Assert.Equal<Salt>(expected, actual);
        }

        [Fact]
        public void opInequality_Salt_SaltTrue()
        {
            Salt obj = new Salt("XbAH5ybjSkZt+Q==");
            Salt comparand = new Salt();

            Assert.True(obj != comparand);
        }

        [Fact]
        public void opInequality_Salt_SaltFalse()
        {
            string value = "XbAH5ybjSkZt+Q==";

            Salt obj = new Salt(value);
            Salt comparand = new Salt(value);

            Assert.False(obj != comparand);
        }

        [Fact]
        public void opInequality_Salt_SaltNull()
        {
            Assert.True(new Salt() != null);
        }

        [Fact]
        public void opInequality_SaltNull_Salt()
        {
            Assert.True(null != new Salt());
        }

        [Fact]
        public void opInequality_Salt_SaltSame()
        {
            Salt obj = new Salt("XbAH5ybjSkZt+Q==");
            Salt comparand = obj;

            Assert.False(obj != comparand);
        }

        [Fact]
        public void op_ToBytes()
        {
            Assert.NotNull(new Salt("XbAH5ybjSkZt+Q==").ToBytes());
        }

        [Fact]
        public void op_Equals_objectSame()
        {
            Salt obj = new Salt();

            Assert.True(obj.Equals(obj as object));
        }

        [Fact]
        public void op_Equals_objectNull()
        {
            Assert.False(new Salt().Equals(null as object));
        }

        [Fact]
        public void op_Equals_objectString()
        {
            string value = "XbAH5ybjSkZt+Q==";
            Salt obj = new Salt(value);

            Assert.False(obj.Equals(value as object));
        }

        [Fact]
        public void op_Equals_objectTrue()
        {
            string value = "XbAH5ybjSkZt+Q==";
            Salt obj = new Salt(value);
            Salt comparand = new Salt(value);

            Assert.True(obj.Equals(comparand as object));
        }

        [Fact]
        public void op_Equals_objectFalse()
        {
            Salt obj = new Salt();
            Salt comparand = new Salt("XbAH5ybjSkZt+Q==");

            Assert.False(obj.Equals(comparand as object));
        }

        [Fact]
        public void op_GetHashCode()
        {
            string value = "XbAH5ybjSkZt+Q==";

            int expected = value.GetHashCode();
            int actual = new Salt(value).GetHashCode();

            Assert.Equal<int>(expected, actual);
        }

        [Fact]
        public void op_ToString()
        {
            string expected = "XbAH5ybjSkZt+Q==";
            string actual = new Salt(expected).ToString();

            Assert.Equal<string>(expected, actual);
        }
    }
}